package com.csust.cg.mongodb.domain.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.io.Serializable;
import java.util.Date;

/**
 * @author chenguang
 */
public class Connect implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    private Integer id;

    /**
     * 用户ID
     */
    private String userId;

    /**
     * 分组ID
     */
    private Integer groupId;

    /**
     * 连接名
     */
    private String name;

    /**
     * mongoDB连接协议，默认mongodb
     */
    private String protocol;

    /**
     * mongoDB连接IP
     */
    private String ip;

    /**
     * mongoDB连接端口
     */
    private Integer port;

    /**
     * 认证方式，false：无，true：用户名密码认证
     */
    private Boolean auth;

    /**
     * 连接类型，false：保存，true：最近
     */
    private Boolean type;

    /**
     * mongoDB连接登陆用户
     */
    private String username;

    /**
     * mongoDB连接登陆密码
     */
    private String password;

    /**
     * 权限数据库，默认admin
     */
    private String authDatabase;

    /**
     * 权限验证机制，默认为DEFAULT
     */
    private String authMechanism;

    /**
     * 创建或更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public Connect() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Integer getGroupId() {
        return groupId;
    }

    public void setGroupId(Integer groupId) {
        this.groupId = groupId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getProtocol() {
        return protocol;
    }

    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public Boolean getAuth() {
        return auth;
    }

    public void setAuth(Boolean auth) {
        this.auth = auth;
    }

    public Boolean getType() {
        return type;
    }

    public void setType(Boolean type) {
        this.type = type;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAuthDatabase() {
        return authDatabase;
    }

    public void setAuthDatabase(String authDatabase) {
        this.authDatabase = authDatabase;
    }

    public String getAuthMechanism() {
        return authMechanism;
    }

    public void setAuthMechanism(String authMechanism) {
        this.authMechanism = authMechanism;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("ID", getId())
                .append("userId", getUserId())
                .append("groupId", getGroupId())
                .append("type", getType())
                .append("name", getName())
                .append("protocol", getProtocol())
                .append("ip", getIp())
                .append("port", getPort())
                .append("auth", getAuth())
                .append("username", getUsername())
                .append("password", getPassword())
                .append("authDatabase", getAuthDatabase())
                .append("authMechanism", getAuthMechanism())
                .append("updateTime", getUpdateTime())
                .toString();
    }
}
